package com.pinxixi.brand.controller;

import com.pinxixi.api.brand.BrandControllerApi;
import com.pinxixi.brand.service.BrandService;
import com.pinxixi.framework.domain.brand.Brand;
import com.pinxixi.framework.model.response.ListResponseResult;
import com.pinxixi.framework.model.response.QueryResponseResult;
import com.pinxixi.framework.model.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/brand")
public class BrandController implements BrandControllerApi {

    @Autowired
    private BrandService brandService;

    @Override
    @GetMapping("/findAll")
    public ListResponseResult<Brand> findAll() {
        return brandService.findAll();
    }

    @GetMapping("/findPage/{page}/{size}")
    public ListResponseResult<Brand> findPage(@PathVariable("page") Integer page,
                                          @PathVariable("size") Integer size,
                                          Brand brand){
        return brandService.findPage(page,size,brand);
    }

    @Override
    @GetMapping("/findOne/{id}")
    public QueryResponseResult<Brand> findOne(@PathVariable("id") Long id) {
        return brandService.findOne(id);
    }

    @Override
    @PostMapping("/save")
    public QueryResponseResult<Brand> save(@RequestBody Brand brand) {
        return brandService.save(brand);
    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteById(@PathVariable("id") Long id) {
        return brandService.deleteById(id);
    }


    @Override
    @DeleteMapping("/deleteAll")
    public ResponseResult deleteAll(Long[] ids) {
        return brandService.deleteAll(ids);
    }


}
